<?php
require "././vendor/autoload.php";

use PhpAmqpLib\Message\AMQPMessage;
use PhpAmqpLib\Connection\AMQPStreamConnection;

$exchangeName = "publishExchange";
$queueName = "publishQueueName";


$host = PHP_OS == "Linux" ? "127.0.0.1" : "10.0.0.200";
$conn = new AMQPStreamConnection($host,'5672','wyqgg','123456');

$ch = $conn->channel();

$ch->exchange_declare($exchangeName,\PhpAmqpLib\Exchange\AMQPExchangeType::FANOUT);
$ch->queue_declare($queueName,false,true);
$ch->queue_bind($queueName,$exchangeName);

$callback  = function (AMQPMessage $message){
   echo $message->getBody().PHP_EOL;
    $message->ack();
    usleep(1000);
};

$ch->basic_consume($queueName,'',false,false,false,false,$callback);


while($ch->is_consuming()){
    $ch->wait();
}

$ch->close();
$conn->close();